package org.spindle.soasuite.parser;

import org.spindle.soasuite.parser.api.IParser;
import org.spindle.soasuite.parser.api.ParserConstants;
import org.spindle.soasuite.parser.json.JSONParser;

import java.util.HashMap;
import java.util.Map;

public class ParserFactory {

    private static Map<String, IParser> parserMap;

    public static IParser getParser(String parserType) {

        if (parserMap == null) {
            parserMap = new HashMap<String, IParser>(ParserConstants.KNOWN_PARSERS);
        }

        IParser parser = parserMap.get(parserType);

        if (parser == null) {
            if (ParserConstants.JSON_PARSER.equals(parserType)) {
                parser = new JSONParser();
            }
        }

        return parser;

    }

}
